package weaver.jobs.cese;

import weaver.conn.RecordSet;
import weaver.general.BaseBean;
import weaver.interfaces.schedule.BaseCronJob;

/**
 * @Title: ecology
 * @Company: 泛微软件
 * @author: weaver.Dusongsong
 * @version: 1.0
 * @CreateDate: 2020-10-30
 * @Description: 定时同步党费信息
 * @ModifyLog:
 **/

public class WeaPartyFeesInfoCronJob extends BaseCronJob {
    @Override
    public void execute() {
        BaseBean baseBean = new BaseBean();
        baseBean.writeLog( "-----------WeaPartyFeesInfoCronJob------------" );
        RecordSet rs = new RecordSet();
        RecordSet rs1 = new RecordSet();
        String sql = "select t1.id,t1.lastname,t1.departmentid,t2.dzz,t1.numberfield1,t3.dyxzbm from hrmresource t1,uf_dydzzbm t2,uf_dzzxzbm t3\n" +
                "where t1.id=t2.dymc and t2.dzz=t3.dzz";
        baseBean.writeLog(sql);
        rs.executeQuery( sql );
        int count1 = 0;
        int count2 = 0;
        while (rs.next()) {
            String id = rs.getString( "id" );//人员ID
            String departmentid = rs.getString( "departmentid" );//部门ID
            String dzz = rs.getString( "dzz" );//党组织
            String numberfield1 = rs.getString( "numberfield1" );//应缴党费
            String nf = "2020";
            String yf = "10";
            String sfjn = "1";
            rs1.executeQuery( "select count(1) uf_yjdfxx where dy='" + id + "'" );
            if (!rs1.next()) {
                rs1.executeUpdate( "insert into uf_yjdfxx(dy,ssbm,ssdzz,nf,yf,yjdf,sfjn)values(?,?,?,?,?,?,?)",id,departmentid,dzz,nf,yf,numberfield1,sfjn);
                count1++;
            } else {
                rs1.executeUpdate( "update uf_yjdfxx set yjdf=?,sfjn=? where dy = ?",numberfield1,sfjn,id);
                count2++;
            }
        }
      baseBean.writeLog("插入数据记录数["+count1+"],更新数据记录数["+count2+"]");
    }
}
